let sum = [6, 1, 2, 1, 4, 6]
let newArr = sum.reduce((t, v) => t.includes(v) ? t : [...t, v], []);
//运行顺序
/*
1.   t=[]        [].includes(6)        执行[...t,v]  //t=[6]
2.   t=[6]       [6].includes(1)       执行[...t,v]  //t=[6,1]
3.   t=[6,1]     [6,1].includes(2)     执行[...t,v]  //t=[6,1,2]
4.   t=[6,1,2]   [6,1,2].includes(1)   执行t   // t=[6,1,2]
5.   t=[6,1,2]   [6,1,2].includes(4)   执行[...t,v]  //t=[6,1,2,4]
6.   t=[6,1,2,4] [6,1,2,4].includes(6) 执行t   // t=[6,1,2,4]
//返回得到t=[6,1,2,4]
*/
console.log(newArr)